<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Login_model extends CI_Model{
    function __construct() {
        parent::__construct();
    }
    
    public function validate(){
        $email = $this->security->xss_clean($this->input->post('inputEmail'));
        $password = $this->security->xss_clean($this->input->post('inputPassword'));
        
        $this->db->where('email',$email);
        $this->db->where('password',$password);
                
        
        $query = $this->db->get('users');
        
        if($query->num_rows == 1)
        {
            $row = $query->row();
            $data = array(
                'user_id' => $row->user_id,
                'email' => $row->email,
                'password' => $row->password, 
                'active' => '1'
            );
            $this->session->setuserdata($data);
            return TRUE;
        }
        return FALSE;
    }
}

?>
